// 封装高阶组件，判断有无token，没有就强制跳转到登录页面
import { getToken } from "@/utils";
import { Navigate } from "react-router-dom";

export function AuthRouter ({children}) {
  const token = getToken()
  if(token){
    return <>{children}</>
  }else{
    // 强制跳转到登录页面
    return <Navigate to={'/login'} replace></Navigate>
  }
}